#include "File/BOSSOutputLoader.h"
#include "File/YamlLoader.h"
#include "Functions/TerminalIO.h"
#include <iostream>
#include <string>

using namespace BOSS_Afterburner::TerminalIO;
using namespace std;

/// @addtogroup Afterburner_scripts
/// @{

/// Print the tree and branch structure and cut flow of the file.
/// @author   Remco de Boer 雷穆克 (r.e.deboer@students.uu.nl or remco.de.boer@ihep.ac.cn)
/// @date     May 19th, 2019
void InvestigateContent(const char* config_file)
{
  YamlLoader conf(config_file);

  bool printbranches = false;
  if(conf["Print cut flow"].IsDefined()) printbranches = conf["Print cut flow"].as<bool>();
  bool printaverages = false;
  if(conf["Print averages"].IsDefined()) printaverages = conf["Print averages"].as<bool>();
  bool printstructure = false;
  if(conf["Print structure"].IsDefined()) printstructure = conf["Print structure"].as<bool>();
  bool printflow = false;
  if(conf["Print cut flow"].IsDefined()) printflow = conf["Print cut flow"].as<bool>();

  const auto&      filename = conf["Input file or directory"];
  BOSSOutputLoader file(filename.as<string>().c_str());
  if(printbranches) file.Print();
  if(printaverages) file.PrintCuts(true);
  if(printstructure) file.PrintStructure();
  if(printflow) file.PrintCutFlow();
}
/// @}

int main(int argc, char* argv[])
{
  CheckMainArguments(argc, argv, 1);
  InvestigateContent(argv[1]);
  return 0;
}